/*
 * @Author: 米亚流年 miyaliunian@gmail.com
 * @Date: 2023-12-29 22:59:49
 * @LastEditors: 米亚流年 miyaliunian@gmail.com
 * @LastEditTime: 2024-03-31 23:08:47
 * @FilePath: /low-comps/packages/docs/vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineConfig } from 'vite'
import createMyPlugin from './plugins'
import UnoCSS from 'unocss/vite'
const { babel } = require('@rollup/plugin-babel')

// https://vitejs.dev/config/
export default defineConfig({
  root: __dirname,
  base: './',
  plugins: [createMyPlugin(), UnoCSS()],
  // resolve: {
  //   alias:
  //     process.env.NODE_ENV !== 'production'
  //       ? [
  //           {
  //             find: 'low-comp',
  //             replacement: path.resolve(__dirname, './src')
  //           },
  //           {
  //             find: 'low-comp/hooks',
  //             replacement: path.resolve(__dirname, './src/hooks.ts')
  //           }
  //         ]
  //       : undefined
  // },
  optimizeDeps: {
    include: [
      'vue',
      'vue-router',
      'codesandbox/lib/api/define',
      'highlight.js/lib/core',
      'highlight.js/lib/languages/javascript',
      'highlight.js/lib/languages/python',
      'highlight.js/lib/languages/cpp',
      'highlight.js/lib/languages/xml',
      '@vicons/ionicons5',
      '@vicons/ionicons4',
      '@vicons/fluent/Compose16Regular.js'
    ]
  },
  build: {
    outDir: 'site',
    // output: {
    //   manualChunks: {
    //     'grapheme-splitter': ['grapheme-splitter'],
    //     'katex': ['katex']
    //   }
    // },
    rollupOptions: {
      plugins: [
        babel({
          babelHelpers: 'bundled'
        })
      ]
    }
  }
})
